/* SPDX-License-Identifier: GPL-2.0 */
/*
 * Copyright (c) Huawei Technologies Co., Ltd. 2023-2023. All rights reserved.
 * Description: Pangea Libata Driver Vendor Hooks
 */

#ifdef CONFIG_VENDOR_PANGEA_LIBATA_HOOKS
#undef TRACE_SYSTEM
#define TRACE_SYSTEM libata_pangea

#define TRACE_INCLUDE_PATH trace/hooks
#if !defined(_TRACE_HOOKS_LIBATA_PANGEA_H) || defined(TRACE_HEADER_MULTI_READ)
#define _TRACE_HOOKS_LIBATA_PANGEA_H
#include <linux/tracepoint.h>
#include <trace/hooks/vendor_hooks.h>

struct ata_port;
struct ata_link;
struct ata_device;
struct ata_queued_cmd;
struct ata_host;
struct ata_eh_info;
struct ata_eh_context;

DECLARE_HOOK(vendor_ata_print,
	TP_PROTO(struct ata_port *ap, const char *msg),
	TP_ARGS(ap, msg));

/* libata-core.c */
DECLARE_HOOK(vendor_ata_exec_internal,
	TP_PROTO(struct ata_port *ap),
	TP_ARGS(ap));

DECLARE_HOOK(vendor_ata_exec_internal_exit,
	TP_PROTO(struct ata_port *ap),
	TP_ARGS(ap));

DECLARE_HOOK(vendor_ata_ignore_error_handler,
	TP_PROTO(void *args),
	TP_ARGS(args));

DECLARE_HOOK(vendor_sata_print_link_status,
	TP_PROTO(struct ata_link *link, u32 sstatus),
	TP_ARGS(link, sstatus));

DECLARE_HOOK(vendor_ata_dev_revalidate,
	TP_PROTO(struct ata_device *dev),
	TP_ARGS(dev));

DECLARE_HOOK(vendor_ata_dev_revalidate_fail_exit,
	TP_PROTO(struct ata_device *dev),
	TP_ARGS(dev));

DECLARE_HOOK(vendor_ata_sim_identify_fail,
	TP_PROTO(struct ata_device *dev, int *rc),
	TP_ARGS(dev, rc));

DECLARE_HOOK(vendor_ata_qc_complete,
	TP_PROTO(struct ata_port *ap, struct ata_queued_cmd *qc, bool *vendor_out),
	TP_ARGS(ap, qc, vendor_out));

DECLARE_HOOK(vendor_ata_host_register,
	TP_PROTO(struct ata_host *host),
	TP_ARGS(host));

/* libata-scsi.c */
DECLARE_HOOK(vendor_translate_sense_done,
	TP_PROTO(u8 drv_err, u8 *sk, u8 *asc, u8 *ascq, bool *vendor_done),
	TP_ARGS(drv_err, sk, asc, ascq, vendor_done));

DECLARE_HOOK(vendor_translate_stat_done,
	TP_PROTO(u8 drv_stat, u8 *sk, u8 *asc, u8 *ascq, bool *vendor_done),
	TP_ARGS(drv_stat, sk, asc, ascq, vendor_done));

DECLARE_HOOK(vendor_ata_scsi_slave_config,
	TP_PROTO(struct scsi_device *sdev, struct ata_device *dev, struct ata_port *ap, int rc),
	TP_ARGS(sdev, dev, ap, rc));

DECLARE_HOOK(vendor_ata_scsi_qc_complete,
	TP_PROTO(struct ata_port *ap, struct scsi_cmnd *cmd, u8 *cdb),
	TP_ARGS(ap, cmd, cdb));

DECLARE_HOOK(vendor_ata_scsi_qc_complete_exit,
	TP_PROTO(struct ata_queued_cmd *qc, struct ata_port *ap, struct scsi_cmnd *cmd),
	TP_ARGS(qc, ap, cmd));

DECLARE_HOOK(vendor_ata_scsi_dump_cdb,
	TP_PROTO(struct ata_port *ap, struct scsi_cmnd *cmd),
	TP_ARGS(ap, cmd));

DECLARE_HOOK(vendor_ata_scsi_queuecmd_block_exit,
	TP_PROTO(struct ata_port *ap, struct Scsi_Host *shost,
		struct scsi_cmnd *cmd, bool *vendor_out),
	TP_ARGS(ap, shost, cmd, vendor_out));

DECLARE_HOOK(vendor_ata_scsi_queuecmd_record_cmd,
	TP_PROTO(struct ata_port *ap, struct scsi_cmnd *cmd, int rc),
	TP_ARGS(ap, cmd, rc));

DECLARE_HOOK(vendor_ata_scsi_handle_link_detach,
	TP_PROTO(struct ata_port *ap, struct ata_device *dev),
	TP_ARGS(ap, dev));

DECLARE_HOOK(vendor_ata_scsi_hotplug,
	TP_PROTO(struct ata_port *ap),
	TP_ARGS(ap));

/* libata-eh.c */
DECLARE_HOOK(vendor_ata_set_eh_reset_deadline,
	TP_PROTO(unsigned long *deadline, int try),
	TP_ARGS(deadline, try));

DECLARE_HOOK(vendor_ata_ehi_push_desc,
	TP_PROTO(struct ata_eh_info *ehi, int desc_len),
	TP_ARGS(ehi, desc_len));

DECLARE_HOOK(vendor_ata_scsi_error_exit,
	TP_PROTO(struct Scsi_Host *host, struct ata_port *ap, int *rc),
	TP_ARGS(host, ap, rc));

DECLARE_HOOK(vendor_ata_scsi_error,
	TP_PROTO(struct Scsi_Host *host, struct ata_port *ap, struct list_head *eh_work_q),
	TP_ARGS(host, ap, eh_work_q));

DECLARE_HOOK(vendor_ata_eh_link_report,
	TP_PROTO(struct ata_port *ap, struct ata_eh_context *ehc),
	TP_ARGS(ap, ehc));

DECLARE_HOOK(vendor_ata_do_reset,
	TP_PROTO(struct ata_link *link, int rc),
	TP_ARGS(link, rc));

DECLARE_HOOK(vendor_ata_eh_reset,
	TP_PROTO(struct ata_port *ap, bool *vendor_fail),
	TP_ARGS(ap, vendor_fail));

DECLARE_HOOK(vendor_ata_eh_handle_dev_fail,
	TP_PROTO(struct ata_eh_context *ehc, struct ata_device *dev, int *rc),
	TP_ARGS(ehc, dev, rc));

DECLARE_HOOK(vendor_ata_eh_recover,
	TP_PROTO(struct ata_port *ap),
	TP_ARGS(ap));

DECLARE_HOOK(vendor_ata_eh_recover_rest_fail_exit,
	TP_PROTO(struct ata_port *ap, struct ata_eh_context *ehc,
		struct ata_device *dev, bool *vendor_out, int rc),
	TP_ARGS(ap, ehc, dev, vendor_out, rc));

DECLARE_HOOK(vendor_ata_eh_recover_nr_fail_exit,
	TP_PROTO(struct ata_device *dev, struct ata_port *ap, bool *vendor_out, int rc),
	TP_ARGS(dev, ap, vendor_out, rc));

/* libata-pmp.c */
DECLARE_HOOK(vendor_sata_pmp_eh_recover_exit,
	TP_PROTO(struct ata_port *ap),
	TP_ARGS(ap));

DECLARE_HOOK(vendor_sata_pmp_eh_recover,
	TP_PROTO(struct ata_port *ap, int *rc, bool *vendor_out),
	TP_ARGS(ap, rc, vendor_out));

DECLARE_HOOK(vendor_sata_pmp_error_handler,
	TP_PROTO(struct ata_port *ap),
	TP_ARGS(ap));

DECLARE_HOOK(vendor_sata_pmp_error_handler_exit,
	TP_PROTO(struct ata_port *ap, int rc),
	TP_ARGS(ap, rc));

/* libata-sata.c */
DECLARE_HOOK(vendor_sata_link_hardreset,
	TP_PROTO(struct ata_link *link, int *rc),
	TP_ARGS(link, rc));

DECLARE_HOOK(vendor_sata_link_scr_lpm,
	TP_PROTO(enum ata_lpm_policy policy, int *rc),
	TP_ARGS(policy, rc));

#endif

 /* This part must be outside protection */
#include <trace/define_trace.h>

#else

#include <linux/tracepoint.h>

struct ata_port;
struct ata_link;
struct ata_device;
struct ata_queued_cmd;
struct ata_host;
struct ata_eh_info;
struct ata_eh_context;

DECLARE_EVENT_NOP(vendor_ata_print,
	TP_PROTO(struct ata_port *ap, const char *msg),
	TP_ARGS(ap, msg));

/* libata-core.c */
DECLARE_EVENT_NOP(vendor_ata_exec_internal,
	TP_PROTO(struct ata_port *ap),
	TP_ARGS(ap));

DECLARE_EVENT_NOP(vendor_ata_exec_internal_exit,
	TP_PROTO(struct ata_port *ap),
	TP_ARGS(ap));

DECLARE_EVENT_NOP(vendor_ata_ignore_error_handler,
	TP_PROTO(void *args),
	TP_ARGS(args));

DECLARE_EVENT_NOP(vendor_sata_print_link_status,
	TP_PROTO(struct ata_link *link, u32 sstatus),
	TP_ARGS(link, sstatus));

DECLARE_EVENT_NOP(vendor_ata_dev_revalidate,
	TP_PROTO(struct ata_device *dev),
	TP_ARGS(dev));

DECLARE_EVENT_NOP(vendor_ata_dev_revalidate_fail_exit,
	TP_PROTO(struct ata_device *dev),
	TP_ARGS(dev));

DECLARE_EVENT_NOP(vendor_ata_sim_identify_fail,
	TP_PROTO(struct ata_device *dev, int *rc),
	TP_ARGS(dev, rc));

DECLARE_EVENT_NOP(vendor_ata_qc_complete,
	TP_PROTO(struct ata_port *ap, struct ata_queued_cmd *qc, bool *vendor_out),
	TP_ARGS(ap, qc, vendor_out));

DECLARE_EVENT_NOP(vendor_ata_host_register,
	TP_PROTO(struct ata_host *host),
	TP_ARGS(host));

/* libata-scsi.c */
DECLARE_EVENT_NOP(vendor_translate_sense_done,
	TP_PROTO(u8 drv_err, u8 *sk, u8 *asc, u8 *ascq, bool *vendor_done),
	TP_ARGS(drv_err, sk, asc, ascq, vendor_done));

DECLARE_EVENT_NOP(vendor_translate_stat_done,
	TP_PROTO(u8 drv_stat, u8 *sk, u8 *asc, u8 *ascq, bool *vendor_done),
	TP_ARGS(drv_stat, sk, asc, ascq, vendor_done));

DECLARE_EVENT_NOP(vendor_ata_scsi_slave_config,
	TP_PROTO(struct scsi_device *sdev, struct ata_device *dev, struct ata_port *ap, int rc),
	TP_ARGS(sdev, dev, ap, rc));

DECLARE_EVENT_NOP(vendor_ata_scsi_qc_complete,
	TP_PROTO(struct ata_port *ap, struct scsi_cmnd *cmd, u8 *cdb),
	TP_ARGS(ap, cmd, cdb));

DECLARE_EVENT_NOP(vendor_ata_scsi_qc_complete_exit,
	TP_PROTO(struct ata_queued_cmd *qc, struct ata_port *ap, struct scsi_cmnd *cmd),
	TP_ARGS(qc, ap, cmd));

DECLARE_EVENT_NOP(vendor_ata_scsi_dump_cdb,
	TP_PROTO(struct ata_port *ap, struct scsi_cmnd *cmd),
	TP_ARGS(ap, cmd));

DECLARE_EVENT_NOP(vendor_ata_scsi_queuecmd_block_exit,
	TP_PROTO(struct ata_port *ap, struct Scsi_Host *shost,
		struct scsi_cmnd *cmd, bool *vendor_out),
	TP_ARGS(ap, shost, cmd, vendor_out));

DECLARE_EVENT_NOP(vendor_ata_scsi_queuecmd_record_cmd,
	TP_PROTO(struct ata_port *ap, struct scsi_cmnd *cmd, int rc),
	TP_ARGS(ap, cmd, rc));

DECLARE_EVENT_NOP(vendor_ata_scsi_handle_link_detach,
	TP_PROTO(struct ata_port *ap, struct ata_device *dev),
	TP_ARGS(ap, dev));

DECLARE_EVENT_NOP(vendor_ata_scsi_hotplug,
	TP_PROTO(struct ata_port *ap),
	TP_ARGS(ap));

/* libata-eh.c */
DECLARE_EVENT_NOP(vendor_ata_set_eh_reset_deadline,
	TP_PROTO(unsigned long *deadline, int try),
	TP_ARGS(deadline, try));

DECLARE_EVENT_NOP(vendor_ata_ehi_push_desc,
	TP_PROTO(struct ata_eh_info *ehi, int desc_len),
	TP_ARGS(ehi, desc_len));

DECLARE_EVENT_NOP(vendor_ata_scsi_error_exit,
	TP_PROTO(struct Scsi_Host *host, struct ata_port *ap, int *rc),
	TP_ARGS(host, ap, rc));

DECLARE_EVENT_NOP(vendor_ata_scsi_error,
	TP_PROTO(struct Scsi_Host *host, struct ata_port *ap, struct list_head *eh_work_q),
	TP_ARGS(host, ap, eh_work_q));

DECLARE_EVENT_NOP(vendor_ata_eh_link_report,
	TP_PROTO(struct ata_port *ap, struct ata_eh_context *ehc),
	TP_ARGS(ap, ehc));

DECLARE_EVENT_NOP(vendor_ata_do_reset,
	TP_PROTO(struct ata_link *link, int rc),
	TP_ARGS(link, rc));

DECLARE_EVENT_NOP(vendor_ata_eh_reset,
	TP_PROTO(struct ata_port *ap, bool *vendor_fail),
	TP_ARGS(ap, vendor_fail));

DECLARE_EVENT_NOP(vendor_ata_eh_handle_dev_fail,
	TP_PROTO(struct ata_eh_context *ehc, struct ata_device *dev, int *rc),
	TP_ARGS(ehc, dev, rc));

DECLARE_EVENT_NOP(vendor_ata_eh_recover,
	TP_PROTO(struct ata_port *ap),
	TP_ARGS(ap));

DECLARE_EVENT_NOP(vendor_ata_eh_recover_rest_fail_exit,
	TP_PROTO(struct ata_port *ap, struct ata_eh_context *ehc,
		struct ata_device *dev, bool *vendor_out, int rc),
	TP_ARGS(ap, ehc, dev, vendor_out, rc));

DECLARE_EVENT_NOP(vendor_ata_eh_recover_nr_fail_exit,
	TP_PROTO(struct ata_device *dev, struct ata_port *ap, bool *vendor_out, int rc),
	TP_ARGS(dev, ap, vendor_out, rc));

/* libata-pmp.c */
DECLARE_EVENT_NOP(vendor_sata_pmp_eh_recover_exit,
	TP_PROTO(struct ata_port *ap),
	TP_ARGS(ap));

DECLARE_EVENT_NOP(vendor_sata_pmp_eh_recover,
	TP_PROTO(struct ata_port *ap, int *rc, bool *vendor_out),
	TP_ARGS(ap, rc, vendor_out));

DECLARE_EVENT_NOP(vendor_sata_pmp_error_handler,
	TP_PROTO(struct ata_port *ap),
	TP_ARGS(ap));

DECLARE_EVENT_NOP(vendor_sata_pmp_error_handler_exit,
	TP_PROTO(struct ata_port *ap, int rc),
	TP_ARGS(ap, rc));

/* libata-sata.c */
DECLARE_EVENT_NOP(vendor_sata_link_hardreset,
	TP_PROTO(struct ata_link *link, int *rc),
	TP_ARGS(link, rc));

DECLARE_EVENT_NOP(vendor_sata_link_scr_lpm,
	TP_PROTO(enum ata_lpm_policy policy, int *rc),
	TP_ARGS(policy, rc));

#endif
